/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *                                                                  *
 *        *************************************************         *
 *        *©2021-2027 HT Corporation All rights reserved *          *
 *        *************************************************         *
 *                                                                  *
 * FileName    : h_venc.c                                           *
 *                                                                  *
 * Author      : linus                                              *
 *                                                                  *
 * Email       : luoyaojun@haitutech.com                            *
 *                                                                  *
 * Date        : 2022-8-17                                          *
 *                                                                  *
 * Description :                                                    *
 *                                                                  *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "h_venc.h"

HT_S32 ht_venc_module_register(struct ht_venc *pvenc)
{
    return (ht_register_modules(HT_ID_VENC, (HT_HANDLE)pvenc));
}

HT_S32 ht_venc_init(HT_U32 chn, HT_U32 u32SrcWidth, HT_U32 u32SrcHeight, HT_CODEC_ID codec)
{
    struct ht_venc *pvenc = HT_MPP_HANDLE_VENC;
    HT_S32 ret = -1;

    if (!pvenc)
        return -1;

    if (pvenc->ops)
        ret = pvenc->ops->venc_init(pvenc, chn, u32SrcWidth, u32SrcHeight, codec);

    return ret;
}

HT_S32 ht_venc_exit(HT_U32 chn)
{
    struct ht_venc *pvenc = HT_MPP_HANDLE_VENC;
    HT_S32 ret = -1;

    if (!pvenc)
        return -1;

    if (pvenc->ops)
        ret = pvenc->ops->venc_exit(pvenc, chn);

    return ret;
}

HT_S32 ht_venc_get_frame(HT_U32 chn, cb_venc_get_frame cb_user, void *user)
{
    struct ht_venc *pvenc = HT_MPP_HANDLE_VENC;
    HT_S32 ret = -1;

    if (!pvenc)
        return -1;

    if (!cb_user)
        return -2;

    if (pvenc->ops)
        ret = pvenc->ops->venc_get_frame(pvenc, chn, cb_user, user);

    return ret;
}

HT_S32 ht_venc_chn_send_frame(HT_U32 chn, void *frame, HT_S32 msec)
{
    struct ht_venc *pvenc = HT_MPP_HANDLE_VENC;
    HT_S32 ret = -1;

    if (!pvenc)
        return -1;

    if (pvenc->ops && pvenc->ops->venc_send_frame)
        ret = pvenc->ops->venc_send_frame(pvenc, chn, frame, msec);

    return ret;
}

HT_S32 ht_venc_chn_stop_recv_frame(HT_U32 chn)
{
    struct ht_venc *pvenc = HT_MPP_HANDLE_VENC;
    HT_S32 ret = -1;

    if (!pvenc)
        return -1;

    if (pvenc->ops)
        ret = pvenc->ops->venc_stop_recv_frame(pvenc, chn);

    return ret;
}

